package com.yiwyn.beans;


import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Slf4j
@Component
public abstract class BaseBean {

    private static final Logger log = LoggerFactory.getLogger(BaseBean.class);
    @Autowired
    protected OtherBean otherBean;

    public String printA() {
        return " BASE A ";
    }

    public String printB() {
        return " BASE B ";
    }


    public abstract String beanKey();


    @PostConstruct
    private void init() {
        log.info("BaseBean init:{}", this.beanKey());
        Router.beanMap.putIfAbsent(beanKey(), this);
    }

}
